package cn.hycat.leetcode.middle;

/**
 * @author 吕泽浩业
 * @version 1.0
 */
public class L53最大子数组和 {
    public int maxSubArray(int[] nums) {
        int cur = nums[0];
        int ans = nums[0];
        for(int i = 1; i < nums.length; i++) {
            cur = Math.max(nums[i], cur + nums[i]);
            ans = Math.max(ans, cur);
        }
        return ans;
    }
}
